package com.corona.game;

import com.corona.Game;

import java.util.Locale;

/* compiled from: Battle.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/AttackAnim.class */
class AttackAnim extends Action {
    public Action.Layer layer = Action.Layer.map_500;
    Attack attack;
    boolean isFriendly;

    public AttackAnim(Game game, Attack attack, boolean isFriendly, Action nextAction) {
        super(new Object[0]);
        this.attack = attack;
        this.isFriendly = isFriendly;
        this.nextAction = nextAction;
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        Action action;
        Pokemon friendlyPokemon;
        game.actionStack.remove(this);
        if (this.attack != null) {
            action = Battle.getAttackAction(game, this.attack, this.isFriendly, null);
        } else {
            action = new Action(new Object[0]);
        }
        if (this.isFriendly) {
            friendlyPokemon = game.player.currPokemon;
            Pokemon pokemon = game.battle.oppPokemon;
        } else {
            friendlyPokemon = game.battle.oppPokemon;
            Pokemon pokemon2 = game.player.currPokemon;
        }
        String enemy = this.isFriendly ? "" : "Enemy ";
        if (friendlyPokemon.status != null) {
            if (friendlyPokemon.status.equals("poison")) {
                int damage = friendlyPokemon.maxStats.get("hp").intValue() / 8;
                if (damage < 1) {
                    damage = 1;
                }
                action.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' hurt by poison!", (String) null, true, true, (Action) new Battle.LoadAndPlayAnimation(game, "status_poison", friendlyPokemon, Battle.depleteHealth(game, !this.isFriendly, damage, new WaitFrames(game, 13, null)))))));
            } else if (friendlyPokemon.status.equals("burn")) {
                int damage2 = friendlyPokemon.maxStats.get("hp").intValue() / 8;
                if (damage2 < 1) {
                    damage2 = 1;
                }
                action.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' hurt by its burn!", (String) null, true, false, Battle.depleteHealth(game, !this.isFriendly, damage2, new WaitFrames(game, 13, null))))));
            } else if (friendlyPokemon.status.equals("toxic")) {
                int damage3 = (friendlyPokemon.maxStats.get("hp").intValue() * friendlyPokemon.statusCounter) / 16;
                if (damage3 < 1) {
                    damage3 = 1;
                }
                action.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' hurt by poison!", (String) null, true, true, (Action) new Battle.LoadAndPlayAnimation(game, "status_poison", friendlyPokemon, Battle.depleteHealth(game, !this.isFriendly, damage3, new WaitFrames(game, 13, null)))))));
                friendlyPokemon.statusCounter++;
            }
        }
        if (friendlyPokemon.volatileStatus.contains("curse")) {
            int damage4 = friendlyPokemon.maxStats.get("hp").intValue() / 4;
            if (damage4 < 1) {
                damage4 = 1;
            }
            action.append(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, enemy + friendlyPokemon.nickname.toUpperCase(Locale.ROOT) + "' hurt by the CURSE!", (String) null, true, false, Battle.depleteHealth(game, !this.isFriendly, damage4, new WaitFrames(game, 13, null))))));
        }
        action.append(this.nextAction);
        game.insertAction(action);
    }
}
